import React, { useEffect } from 'react';
import { useLocation, useNavigate, Outlet } from 'react-router-dom';

const Redirect = (props: { from: 'string'; to: 'string' }) => {
  const navigate = useNavigate();
  const location = useLocation();
  useEffect(() => {
    location.pathname === props.from && navigate(props.to);
  });
  return <Outlet />;
};

export default Redirect;
